package mapred.base;

import java.io.IOException;
import java.util.Iterator;

import mapred.config.AdvancedMapReduceBase;

import org.apache.hadoop.io.Writable;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reducer;
import org.apache.hadoop.mapred.Reporter;

public abstract class AbstractReducer<Ki extends Writable, Vi extends Writable, Ko extends Writable, Vo extends Writable>
        extends AdvancedMapReduceBase<Ko, Vo> implements
        Reducer<Ki, Vi, Ko, Vo> {

    @Override
    public void reduce(Ki key, Iterator<Vi> values,
            OutputCollector<Ko, Vo> output, Reporter reporter)
            throws IOException {
        this.setOutput(output);
        this.setReporter(reporter);

        reduce(key, values);
    }

    public abstract void reduce(Ki key, Iterator<Vi> values) throws IOException;

}
